package com.xlro.dao;

import com.xlro.domain.Book;
import com.xlro.domain.BorrowBooks;
import com.xlro.domain.BrowseBook;
import com.xlro.domain.CollBook;
import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.*;

public class BookDaoTest {

    BookDao bookDao = new BookDao();

    @Test
    public void getAllBook() {
        ArrayList<Book> books = bookDao.getAllBook();
        for (Book book :
                books) {
            System.out.println(book.getName());
        }
    }

    @Test
    public void borrowBookNum() {
        System.out.println(bookDao.borrowBookNum("1", "1"));

    }

    @Test
    public void insertBorrowBooks() {
        System.out.println(bookDao.insertBorrowBooks("1", "5","1","3"));
    }

    @Test
    public void selectBrowseBook() {

        ArrayList<BorrowBooks> browseBooks = bookDao.selectBorrowBook("1");
        for (BorrowBooks b :
                browseBooks) {
            System.out.println(b.getId());
        }
    }

    @Test
    public void alterCollBook() {
        System.out.println(bookDao.alterCollBook("1", "1", "2021年5月26日"));
    }

    @Test
    public void collBookNumByBookId() {

        ArrayList<CollBook> x = bookDao.collBookNumByBookId("1");
        System.out.println(x.get(1).getCollectTime());
    }

    @Test
    public void delAllColBook() {
        System.out.println(bookDao.delAllColBook("1"));
    }
}